//
//  MyTableViewCell.m
//  Funny
//
//  Created by dllo on 15/10/28.
//  Copyright © 2015年 King. All rights reserved.
//

#import "MyTableViewCell.h"

@implementation MyTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.content = [[UILabel alloc]init];
        [self.contentView addSubview:self.content];
        self.content.numberOfLines = 5;
        self.content.font = [UIFont systemFontOfSize:14];
        self.content.textColor = [UIColor grayColor];
        
        self.pic = [[UIImageView alloc]init];
        [self.contentView addSubview:self.pic];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.pic.frame = CGRectMake(10, 10, (SelfHeight - 20) / 2 * 3, SelfHeight - 20);
    self.content.frame = CGRectMake((SelfHeight - 20) / 2 * 3 + 15, 10, SelfWidth - (SelfHeight - 20) / 2 * 3 - 20, SelfHeight - 20);
}

- (void)setModel:(MainIntroductionModel *)model
{
    [self.pic sd_setImageWithURL:[NSURL URLWithString:model.mainpic]placeholderImage:[UIImage imageNamed:@"chartlet_image_traning@2x.png"]];
    self.content.text = model.brief;
}

- (void)setDetailModel:(Detail *)detailModel
{
    [self.pic sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://cdn.yaochufa.com/%@",detailModel.imageurl]] placeholderImage:[UIImage imageNamed:@"chartlet_image_traning@2x.png"]];
      self.content.text = detailModel.productName;
    NSLog(@"%@",[NSString stringWithFormat:@"http://cdn.yaochufa.com/%@",[[detailModel.imageList firstObject] objectForKey:@"url"]]);
}

- (void)setInfoModel:(FoodInfoModel *)infoModel
{
    [self.pic sd_setImageWithURL:[NSURL URLWithString:infoModel.pic] placeholderImage:[UIImage imageNamed:@"chartlet_image_traning@2x.png"]];
    self.content.text = infoModel.content;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
